import request from "@/utils/request";
import type {
  GetRoleListApiParams,
  GetRoleListApiResponse,
  GetRolePermissionListApiResponse,
} from "./model/roleModel";

const enum Api {
  getRoleList = "/admin/acl/role",
  addRole = "/admin/acl/role/save",
  getRolePermissionList = "/admin/acl/permission/toAssign",
  assignRolePermissionList = "/admin/acl/permission/doAssign",
}

export const getRoleListApi = ({
  page,
  limit,
  roleName,
}: GetRoleListApiParams) => {
  return request.get<any, GetRoleListApiResponse>(
    Api.getRoleList + `/${page}/${limit}`,
    { params: { roleName } }
  );
};

export const addRoleApi = (roleName: string) => {
  return request.post<any, null>(Api.addRole, { roleName });
};
